//
//  RootViewController.m
//  ComptesColloc
//
//  Created by Romain Niamor on 02/05/11.
//  Copyright 2011 EMN. All rights reserved.
//

#import "RootViewController.h"

@implementation RootViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

/*
 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations.
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
 */

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    sectionArray =  [[NSArray arrayWithObjects:@"Colloc", @"Liste", @"Synthese", @"Histo", nil] retain];
	
	return [sectionArray count];
}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	
	NSString *sectionHeader = nil;
	
	if(section == 0) {
		sectionHeader = @"Colloc";
	}
	if(section == 1) {
		sectionHeader = @"Listing actuel";
	}
    if(section == 2) {
		sectionHeader = @"Synthèse";
	}
    if(section == 3) {
		sectionHeader = @"Historique";
	}
	
	return sectionHeader;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	int coucou;
    
	if(section == 0) {
		contentArray = [[NSArray arrayWithObjects:@"Romain", @"Marion",@"Romains", @"Erwan", nil] retain];
        coucou= [contentArray count];

	}
	else if(section == 1) {
        
		contentArraySection1 = [[NSArray arrayWithObjects:@"Consulter toutes les dépenses", nil] retain];
        coucou= [contentArraySection1 count];

	}
    else if(section == 2) {
        
		contentArraySection2 = [[NSArray arrayWithObjects:@"Tableau récapitulatif", nil] retain];
        coucou= [contentArraySection2 count];
        
	}
    else if(section == 3) {
        
		contentArraySection3 = [[NSArray arrayWithObjects:@"Consulter l'historique", @"Archiver les dépenses en cours", nil] retain];
        coucou= [contentArraySection3 count];
        
	}
    return coucou;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	
	static NSString *identity = @"MainCell";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    
	
	if(cell == nil)
	{
		cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0) reuseIdentifier:identity] autorelease];
	}
    
    if(indexPath.section == 0) {
        [cell.textLabel setText:[contentArray objectAtIndex:indexPath.row]];
	}
	if(indexPath.section == 1) {
        [cell.textLabel setText:[contentArraySection1 objectAtIndex:indexPath.row]];
	}
    if(indexPath.section == 2) {
        [cell.textLabel setText:[contentArraySection2 objectAtIndex:indexPath.row]];
	}
    if(indexPath.section == 3) {
        [cell.textLabel setText:[contentArraySection3 objectAtIndex:indexPath.row]];
	}
	return cell;
}


/*
 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell.
    return cell;
}
 */

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        // Delete the row from the data source.
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
    else if (editingStyle == UITableViewCellEditingStyleInsert)
    {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    /*
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
    // ...
    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
    [detailViewController release];
	*/
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload
{
    [super viewDidUnload];

    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}

- (void)dealloc
{
    [super dealloc];
}

@end
